<?php

namespace app\admin\model\activityform;

use think\Model;

class Fromurldata extends Model
{
    // 表名
    protected $name = 'activityform_fromurldata';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'false';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [

    ];

    public function getNameofall($fromurl_id = NULL)
    {
        $list =  $this->where('fromurl_id',$fromurl_id)->order('id desc')->select();
        $list = collection($list)->toArray();

        $i = 1;
        foreach ($list as &$v){
            $v['ids'] = $i;
            $i++;
        }
        unset($v);

        return $list;
    }

    public function getNameofColumn($fromurl_id = NULL)
    {
        $list =  $this->where('fromurl_id',$fromurl_id)->field('id,name,weixin,phone,createtime,customdata')->order('id desc')->select();
        $list = collection($list)->toArray();

        $i = 1;
        foreach ($list as &$v){
            $v['id'] = $i;
            $i++;
        }
        unset($v);

        return $list;
    }
}
